package panel.media
{
	import assists.HtmlText;
	import assists.TextFieldUtils;
	
	import com.greensock.TweenLite;
	
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.text.TextField;

	/**
	 *滚动字幕平 
	 * @author clouree
	 * 
	 */	
	public class TextScrollAuto extends Sprite
	{
		private var _text:TextField;
		private var _mask:Shape;
		public function TextScrollAuto()
		{
			super();
			init();
		}
		
		private function init():void
		{
			_text = new TextField();
			_text.y = 50;
			_text.wordWrap = true;
			_text.mouseEnabled = false;
			_text.autoSize = "left";
			_text.multiline = true;
			_mask = new Shape();
			this.addChild(_text);
			this.addChild(_mask);
		}
		
		public function playScroll(showStr:String,speed:Number,showWid:int,showHei:int):void
		{
			TextFieldUtils.setHtmlText(_text,HtmlText.formatSizeColor(showStr,0xffffff,26));
			_text.width = showWid;
			
			if(_text.height > showHei)
			{
			_mask.graphics.clear();
			_mask.graphics.beginFill(0);
			_mask.graphics.drawRect(0,0,showWid,showHei);
			_mask.graphics.endFill();
			
			_text.mask = _mask;
			
			TweenLite.to(_text,40,{y:_text.y - _text.height - 50});
			}
				
			
		}
		
	}
}